package juc.lock;

import java.util.concurrent.TimeUnit;


public class Test2 {

    public static void main(String[] args) {


        Phone phone = new Phone();

        // synchronized方法 上锁的是方法调用者对象 phone引用
        // sayHello 没有锁 不受synchronized
        new Thread(()->{
            phone.sendMsg();
        },"a").start();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(()->{
            phone.call();
        },"b").start();
        phone.sayHello();

        new Thread(()->{
        },"c").start();


    }


}


